// rewrited by Zhangdi(zhangdiwaa@163.com) and Hanyuping(yuping0713@126.com)

(function() {
  $(function() {
    $('.datatable').dataTable({
      aoColumnDefs: [
        {
          bSortable: false,
          aTargets: [0, 5]
        }
      ],
      aaSorting: []
    });
    return $(".datatable").each(function() {
      var datatable, length_sel, search_input;
      datatable = $(this);
      search_input = datatable.closest(".dataTables_wrapper").find("div[id$=_filter] input");
      search_input.attr("placeholder", "搜索");
      search_input.addClass("form-control input-sm");
      length_sel = datatable.closest(".dataTables_wrapper").find("div[id$=_length] select");
      length_sel.addClass("form-control input-sm");
      length_sel = datatable.closest(".dataTables_wrapper").find("div[id$=_info]");

      var add_html = '<a class="btn btn-info btn-top btn-user" role="button" href="#">' +
                     '<em class="icon-mail-reply icon-white"> ' +
                     '</em>' + 
                     '&nbsp;导出所有' + 
                     '</a>' +
                     '&nbsp;&nbsp;' ;
                                
      $('.dataTables_wrapper .pull-right:first-child').append(add_html);

      return length_sel.css("margin-top", "18px");
    });
  });

}).call(this);
